﻿using System;
using System.Linq.Expressions;

namespace Yto.Linq
{
    public static class ExpressionHelper<TE, TPK> where TE : class
    {
        public static Expression<Func<TE, bool>> CreateExpressForGetByID(TPK id)
        {
            ParameterExpression param = Expression.Parameter(typeof(TE));
            BinaryExpression lambdaExpression = Expression.Equal(Expression.PropertyOrField(param, "Id"),
                Expression.Constant(id, typeof(TPK)));
            return Expression.Lambda<Func<TE, bool>>(lambdaExpression, param);
        }
    }
}
